﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Perceiveit.Xml
{
    public class XPropertyDictionaryBag : IXPropertyBag
    {
        private Dictionary<XProperty, XPropertyCell> _dict = new Dictionary<XProperty,XPropertyCell>();

        #region IXPropertyBag Members

        public int Count
        {
            get { return _dict.Count(); }
        }

        public bool TryGetCell(XProperty property, out XPropertyCell cell)
        {
            if (_dict.Count == 0)
            {
                cell = null;
                return false;
            }
            else
                return _dict.TryGetValue(property, out cell);
        }

        public void SetCell(XProperty property, XPropertyCell cell)
        {
            _dict[property] = cell;
        }

        public void ClearCell(XProperty property)
        {
            _dict.Remove(property);
        }

        #endregion
    }
}
